// 添加商品数量的逻辑方法
export const addShop = (state, action) => {
    // [action.name] -- 获取需要修改的键
    // state[action.name] -- 根据键从 state 中找到对应的数值 + 1
    // const newState = {...state, [action.name]: state[action.name] + 1}
    return { ...state, [action.name]: state[action.name] + 1 }
  }
  
  // 减少商品数量的逻辑方法
  export const subShop = (state, action) => {
    // const newState = {...state, [action.name]: state[action.name] -1}
    let maxNum = state[action.name]
    if (maxNum <= 0) return { ...state }
    return {...state, [action.name]: state[action.name] -1}
  }